<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<div class="span8 offset2">
    <form class="form-horizontal well" method="POST" action="MainServlet?action=user.save" onsubmit="return checkUser();">
        <fieldset>
            <legend>New user</legend>
            <div class="hidden">
                <input type="hidden" name="id" value="0">
            </div>         

            <div id="userNameControlGroup" class="control-group">
                <label class="control-label" for="userName">User name:</label>
                <div class="controls">
                    <input class="myinput" type="text" id="userName" name="userName" value="">
                    <span id="userNameHelpInline" class="help-inline"></span>
                </div>
            </div>

            <div id="userRoleControlGroup" class="control-group">
                <label class="control-label" for="userRole">User role:</label>
                <div class="controls">
                    <select class="myinput" id="userRole" name="userRole">
                        <option value="0" disabled="true" selected="true">choose user role</option>
                        <c:forEach var="userRole" items="${userRoleList}">
                            <option value="<c:out value="${userRole.toString()}" />"><c:out value="${userRole.toString()}" /></option>
                        </c:forEach>
                    </select>
                    <span id="userRoleHelpInline" class="help-inline"></span>
                </div>
            </div>

            <div id="loginControlGroup" class="control-group">
                <label class="control-label" for="login">Login:</label>
                <div class="controls">
                    <input class="myinput" type="text" id="login" name="login" value="">
                    <span id="loginHelpInline" class="help-inline"></span>
                </div>
            </div>

            <div id="passwordControlGroup" class="control-group">
                <label class="control-label" for="password">Password:</label>
                <div class="controls">
                    <input class="myinput" type="text" id="password" name="password" value="">
                    <span id="passwordHelpInline" class="help-inline"></span>
                </div>
            </div>

            <div class="form-actions">
                <input type="submit" class="btn btn-primary" name="saveButton" value="Create new user">
                <button class="btn" id="cancelButton" name="cancelButton" data-button-to-click="cancelButtonOutOfForm">Cancel</button>
            </div>
            
        </fieldset>
    </form>
    
    <button class="btn" id="cancelButtonOutOfForm" data-link="user-list" style="display: none; visibility: hidden; height: 0px; width: 0px;">Cancel</button>    
</div>